import sys,os
os.chdir(os.path.dirname(__file__))
sys.path.append(os.path.dirname(__file__))

from CustomPack.selenium.CustomEdge import *
from CustomPack.custom import *






if __name__ == "__main__":
    #  判断是否需要强制开启,不需要等待.
    if sys.argv.__len__() > 1:
        if sys.argv[1] == "--force":
            CustomWebDriver.close_all_msedge_process()
            CustomWebDriver.start_debugmode_browser()
            exit(0)
    
    
    # 1.获取当前是否存在浏览器进程
    
    CheckResul_Process = CustomWebDriver.checkout_has_msedge_process()
    if(CheckResul_Process == False):
        CustomWebDriver.start_debugmode_browser()
        exit(0)
    
    # 2.判断是否是调试模式
    CheckResul_DebugModu = CustomWebDriver.checkout_debug_mode_activate()
    if(CheckResul_DebugModu == False):
        _select_execute = customfunction._custom_message(text="是否要全部关闭,重新打开!",type=1)
        
        # 判断选择那种方式启动浏览器
        match _select_execute:
            case 1:
                CustomWebDriver.close_all_msedge_process()
                CustomWebDriver.start_debugmode_browser()
            case 2:
                exit(0)
    else:
        _select_execute = customfunction._custom_message(text="当前环境正是调试模式下的浏览器!\n因此不用重新创建\n\n\n如果需要全部关闭重新启动的话,请选择!\n选择是的话,会关闭当前所有的浏览器进程,以最纯净的环境启动.",type=1)
        
        if _select_execute == 1:
            CustomWebDriver.close_all_msedge_process()
            CustomWebDriver.start_debugmode_browser()
    
    